# 默认目标，执行make时会执行这个目标
all: build.convert-tunnel-sender build.convert-tunnel-receiver

before.build:
	go mod download && go mod vendor

build.test:
	@echo "Building test binaries..."
	@go build -o ospf-client-gopacket test/ospf/client/client.go
	@go build -o ospf-server-gopacket test/ospf/server/server.go
	@go build -o ospf-client test/ospf_raw_socket/client/client_linux.go
	@go build -o ospf-server test/ospf_raw_socket/server/server_linux.go

build.convert-tunnel-sender:
	@echo "build in ${PWD}";go build -o tunnel-sender cmd/client/main.go;sudo setcap cap_net_raw+eip tunnel-sender

build.convert-tunnel-receiver:
	@echo "build in ${PWD}";go build -o tunnel-receiver cmd/server/server.go;sudo setcap cap_net_raw+eip tunnel-receiver

# 清理编译产生的文件
clean:
	@echo "Cleaning..."
	@rm -f tunnel-sender tunnel-receiver ospf-client ospf-server
	@rm -rf vendor
	@echo "Clean complete"

.PHONY: all before.build build.test build.convert-tunnel-sender build.convert-tunnel-receiver clean
